﻿using System;
using System.Xml;

namespace Draco.OWF.Utils
{
    public class XmlUtils
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static XmlElement getChildElement(XmlElement parent,String name)
        {
            if (parent != null && ! String.IsNullOrWhiteSpace(name))
            {
                XmlNodeList list =parent.GetElementsByTagName(name);
                if (list != null && list.Count > 0)
                    return list[0] as XmlElement;
            }
            return null;
        }

        public static String getChildValue(XmlElement parent, String name)
        {
            XmlElement el = getChildElement(parent, name);
            return el == null ? "" : el.InnerText;
        }
    }
}
